//
//  UIButton+Animations.m
//  maintain
//
//  Created by 郑想 on 15/10/20.
//  Copyright © 2015年 ewin. All rights reserved.
//

#import "UIButton+Animations.h"

@implementation UIButton (Animations)

- (void)shakeWithVelocity:(NSNumber*)velocity completionBlock:(animationsCompletionBlock)block
{
    POPSpringAnimation* positionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
    positionAnimation.velocity = velocity;
    positionAnimation.springBounciness = 20;
    [positionAnimation setCompletionBlock:^(POPAnimation* animation, BOOL finished) {
        self.userInteractionEnabled = YES;
        if (block) {
            block();
        }
    }];
    [self.layer pop_addAnimation:positionAnimation forKey:@"positionAnimation"];
}

@end
